﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>selInfo</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<th:block th:include="include :: header('安全管理')" />
	<link href="/hddata/uiduck/css/uiduck.css" type="text/css" rel="stylesheet">
	<link href="/hddata/uiduck/css/table.css" type="text/css" rel="stylesheet">
	
</head>
<body>
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="form1">
					<div class="select-list">
						<ul>
							<li style="background: aliceblue;" th:each="usbState : ${usbStateList}">
								<div style="margin-bottom: 10px;font-size: initial;font-family: fantasy;">
									U口位置：[[${usbState.location}]]
									<br/>
									U口状态：<span th:if="${usbState.portState == 'true'}">启用</span><span th:if="${usbState.portState == 'false'}">停用</span>
								</div>
								<a class="btn btn-danger btn-rounded btn-sm" th:onclick="changePort([[${usbState.location}]],[[${usbState.portState}]],2)"><i class="fa fa-hand-paper-o"></i>&nbsp;停用</a>
								<a class="btn btn-primary btn-rounded btn-sm" th:onclick="changePort([[${usbState.location}]],[[${usbState.portState}]],1)"><i class="fa fa fa-hand-peace-o"></i>&nbsp;启用</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<!--
			<div class="btn-group-sm" id="toolbar1" role="group">
				<a class="btn btn-success" onclick="options1()">
					<i class="fa fa-search"></i> options
				</a>
				<a class="btn btn-success" onclick="$.operate.add()">
					<i class="fa fa-plus"></i> 新增
				</a>
				<a class="btn btn-primary single disabled" onclick="$.operate.edit()">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
					<i class="fa fa-remove"></i> 删除
				</a>
			</div>
			
			
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-warning" onclick="applyDevice()">
					<i class="fa fa-plus"></i> 设备接入申请
				</a>
				<a class="btn btn-danger" onclick="applyDevice()">
					<i class="fa fa-remove"></i> USB禁用
				</a>
				<a class="btn btn-success" onclick="applyDevice()">
					<i class="fa fa-edit"></i> USB启用
				</a>
			</div>
			-->
			<div class="col-xs-12 select-table table-striped">
				<div id="sel_table"></div>
			</div>
		</div>
	</div>
</body>
<th:block th:include="include :: footer" />
<script language="Javascript" src="/hddata/uiduck/js/json2.js"></script>
<script language="Javascript" src="/hddata/uiduck/js/uiduck.js"></script>
<script language="javascript">
	var sel_table = new uiduck('sel_table', {
		templateId: "sel_table",
		loading: {
			icon: "uiduck-loading-6"
		},
		page: true,
		pageOptions: {
			limit: 10,
			limits: ['5', '10', '15', '20', '25']
		},
		fieldOptions: [
			{
				index: true,
				title: "序号"
			},{
				key: "location",
				title: "U口位置"
			}, {
				key: "portState",
				title: "U口禁用状态",
				computed: { "true": "启用", "false": "禁用" }
			}, {
				key: "isAllow",
				title: "是否合法"
			}, {
				key: "action",
				title: "拔插动作"
			}, {
				key: "time",
				title: "记录时间"
			}
		]
	});
	//var dataNew = '[(${selList})]';
	var dataNew = [(${usbLogList})]
	sel_table.setData(dataNew, false);
	
	function changePort(usbLocation,nowState,option){
		if(option == 1){//启用
			if(nowState == "true"){
				$.modal.msg("当前为启用状态，无需操作!");
				return;
			}
		}
		
		if(option == 2){//停用
			if(nowState == "false"){
				$.modal.msg("当前为停用状态，无需操作!");
				return;
			}
		}
		
		//发送AJAX请求
	   	 $.ajax({
           url: "/hddata/changeUsbState",
           data: {
        	   "usbLocation" : usbLocation,
        	   "usbPortState" : nowState,
        	   "usbOption" : option
           },
           type: "post",
           success: function(result) {
           	if (result.code == web_status.SUCCESS) {
           		   $.modal.msg("修改成功!");
           		   refreshTab();//刷新界面
               } else {
               	   $.modal.msg(result.msg);
               }
           }
       })　　　
	}
</script>

</html>